import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicReference;

public class Test {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {

        AtomicReference<Integer> a = new AtomicReference<>();

        a.set(1);
        int b = a.compareAndExchange(1,0);
        System.out.println(a);
        System.out.println(b);
    }
}
